package com.asia5b.a5mall.middleware.logic.viewmodel.order

import androidx.lifecycle.MutableLiveData
import com.asia5b.a5mall.middleware.base.SimpleViewModel
import com.asia5b.a5mall.middleware.model.base.ResultModel
import com.asia5b.a5mall.middleware.model.order.DiffDetailModel
import io.reactivex.functions.Consumer

/**
 * Created by zhangyuncai on 2020/3/23.
 */
class DiffOrderActivityVM : SimpleViewModel() {

    fun getDiffDetail(orderId: Int) {
        baseSubscribe(cartApi.getDiffDetail(orderId), Consumer {
            if (it.isSuccess) {
//                providerView().getDiffDetailResult(it.data!!)
                getDiffDetailResultLiveData.value=it.data!!
            }
        })
    }

    val getDiffDetailResultLiveData = MutableLiveData<DiffDetailModel>()
    val startPayResultLiveData = MutableLiveData<Array<Any>>()

    fun startPay(orderId: Int, amount: Double) {
        baseSubscribe(tradeApi.startPay(orderId, "${amount}"), Consumer {
            if (it.isSuccess) {
//                providerView().startPayResult(it, amount)
                startPayResultLiveData.value= arrayOf(it,amount)
            }
        })
    }
}